/*
Hermes Core: General Purpose Mobile Agent Platform
Copyright (C) 2006 UNICAM - Università degli Studi di Camerino

Group leaders: Flavio Corradini and Emanuela Merelli

Developers: Ezio Bartocci, Diego Bonura, Rosario Culmone,
Davide Lorenzoli, Leonardo Mariani, Francesca Piersigilli, 
Lorenzo Scortichini, Leonardo Vito.

GNU Lesser Public License

This library is free software; you can redistribute it 
and/or modify it under the terms of the GNU Lesser General 
Public License as published by the Free Software Foundation, 
version 2.1 of the License.

This library is distributed in the hope that it will be useful, 
but WITHOUT ANY WARRANTY; without even the implied warranty of 
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
See the GNU Library General Public License for more details.

You should have received a copy of the GNU Library General Public 
License along with this library; if not, write to the
Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.

Emanuela Merelli
Dipartimento di Matematica ed Informatica
Università di Camerino
via Madonna delle Carceri, 62032 Camerino, Italy
E.Mail: emanuela.merelli@unicam.it
*/
package hermesV2;

import hermesV2.agent.Identificator;

import java.io.Serializable;


/**
 * It represents the message exchange between user agents and service agents.
 *
 * @author Diego Bonura
 */
public class Message<T> implements Serializable {
    /**
	 * 
	 */
	private static final long serialVersionUID = -4130959592511818005L;

	/** The indentificator of the sender agent. */
    private Identificator senderAgentId;

    /** The identificator of the receiver agent. */
    private Identificator receiverAgentId;

    /** The object contained into the message. */
    private T object;

    /**
     * Creates a new Message object.
     *
     * @param senderAgentId The identificator of the sender agent.
     * @param receiverAgentId The identificator of the receiver agent.
     * @param object The object to contain into the message.
     */
    public Message (Identificator senderAgentId, Identificator receiverAgentId, T object) {
        this.senderAgentId = senderAgentId;
        this.receiverAgentId = receiverAgentId;
        this.object = object;
    }

    /**
     * Returns the identificator of the sender agent.
     *
     * @return The identificator of the sender agent.
     */
    public Identificator getSenderAgentId() {
        return senderAgentId;
    }

    /**
     * Returns the identificator of the receiver agent.
     *
     * @return The identificator of the receiver agent.
     */
    public Identificator getReceiverAgentId() {
        return receiverAgentId;
    }

    /**
     * Returns the object into the current message (usually an InteractionContainer).
     *
     * @return The object contained into the message.
     */
    public T getObject() {
        return object;
    }

    /**
     * Converts the object to a string.
     *
     * @return The string.
     */
    public String toString() {
        return "Message= From:" + senderAgentId + " To:" + receiverAgentId;
    }
}
